The compiler as a language processor compiles a source program created by a user and generates an executable application (also called an object program). By describing a source program while specifying optimization options, the user may cause the compiler to optimize the application, and thereby improve performance of the application. Particularly, in the field of high performance computing (HPC), reducing the program execution time is important, and the optimization by the compiler (called a compiler optimization) has been attracting attention.
As a compiler optimization, a technique called the constant propagation is known. The constant propagation is a technique that replaces, for example, a variable in a mathematical expression with a constant when compiling. It is common that constant calculation based on the constant propagation is executed in the middle end or the back end of the compiler. On the contrary, a very simple constant calculation is executed in the front end. Although a function of the constant calculation based on the constant propagation may be implemented in the front end, this is not preferable since the implemented function is processor-dependent and the compilation time may increase.
In 2011, the standard called C++11 was established, and a specifier called constexpr (generalized CONSTant EXPRessions) was introduced. The user may add constexpr to a variable, a function and a class in the source program and thereby cause the front end of the compiler to execute constant calculation thereof. When the constant propagation is used, the constant calculation is performed every time an optimization function is applied. Meanwhile, constexpr enables the constant calculation at one time and thereby reduces the compilation time.
As for examples of related techniques, Japanese Laid-open Patent Publication Nos. 09-006627 and 10-40114 and Japanese National Publication of International Patent Application No. 06-501579, are known.